package com.vf.activity.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vf.common.annotation.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vf.common.annotation.Log;
import com.vf.common.core.controller.BaseController;
import com.vf.common.core.domain.AjaxResult;
import com.vf.common.enums.BusinessType;
import com.vf.activity.domain.ActivitiesType;
import com.vf.activity.service.IActivitiesTypeService;
import com.vf.common.utils.poi.ExcelUtil;
import com.vf.common.core.page.TableDataInfo;

/**
 * 活动类型Controller
 * 
 * @author LBS
 * @date 2025-06-05
 */
@RestController
@RequestMapping("/activity/type")
@Api(tags="活动类型")
public class ActivitiesTypeController extends BaseController
{
    @Autowired
    private IActivitiesTypeService activitiesTypeService;

    /**
     * 查询活动类型列表
     */
    @PreAuthorize("@ss.hasPermi('activity:type:list')")
    @GetMapping("/list")
    @ApiOperation("查询活动类型列表")
    @Anonymous
    public TableDataInfo list(ActivitiesType activitiesType)
    {
        startPage();
        List<ActivitiesType> list = activitiesTypeService.selectActivitiesTypeList(activitiesType);
        return getDataTable(list);
    }

    /**
     * 导出活动类型列表
     */
    @PreAuthorize("@ss.hasPermi('activity:type:export')")
    @Log(title = "活动类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivitiesType activitiesType)
    {
        List<ActivitiesType> list = activitiesTypeService.selectActivitiesTypeList(activitiesType);
        ExcelUtil<ActivitiesType> util = new ExcelUtil<ActivitiesType>(ActivitiesType.class);
        util.exportExcel(response, list, "活动类型数据");
    }

    /**
     * 获取活动类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activitiesTypeService.selectActivitiesTypeById(id));
    }

    /**
     * 新增活动类型
     */
    @PreAuthorize("@ss.hasPermi('activity:type:add')")
    @Log(title = "活动类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivitiesType activitiesType)
    {
        return toAjax(activitiesTypeService.insertActivitiesType(activitiesType));
    }

    /**
     * 修改活动类型
     */
    @PreAuthorize("@ss.hasPermi('activity:type:edit')")
    @Log(title = "活动类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivitiesType activitiesType)
    {
        return toAjax(activitiesTypeService.updateActivitiesType(activitiesType));
    }

    /**
     * 删除活动类型
     */
    @PreAuthorize("@ss.hasPermi('activity:type:remove')")
    @Log(title = "活动类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activitiesTypeService.deleteActivitiesTypeByIds(ids));
    }
}
